/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package bouchingballexample;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JFrame;

/**
 *
 * @author WIN7
 */
/**
 * Main Program for running the bouncing ball as a standalone application.
 */
public class BouchingBallExample {
    // Entry main program
   public static void main(String[] args) {
      // Run UI in the Event Dispatcher Thread (EDT), instead of Main thread
      javax.swing.SwingUtilities.invokeLater(new Runnable() {
         public void run() {
            JFrame frame = new JFrame("A World of Balls");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setContentPane(new BallWorld(640, 480)); // BallWorld is a JPanel
            frame.pack();            // Preferred size of BallWorld
            frame.setVisible(true);  // Show it
            frame.addKeyListener(new KeyListener() {
                    public void keyTyped(KeyEvent e) {
                    }
                    public void keyPressed(KeyEvent e) {
                         if(e.getKeyCode() == KeyEvent.VK_ESCAPE){
                            System.gc();
                            System.exit(0);
                        }
                    }
                    public void keyReleased(KeyEvent e) {
                    }
                });
         }
      });
   }
}
